#include "MyShape.h"

//Effect - Base class
class MyEffect: public MyShape
{
protected:
	MyShape* shape;
public:
	MyEffect() {
	}
	void SetShape(MyShape* shape) {
		this->shape = shape;
	}
	void Draw() {
		shape->Draw();
	}
	string ToString() {
		//To be implemented
		string s = "";		
		return s;
	}
	string GetName() {
		return "MyEffect";
	}
};
//Shadow effect - derived class
class MyShadow : public MyEffect
{
private:
	float _strokeWidth;
	char* _stroke;

private:
	void DrawShadow() {		
		if(shape->GetName() == "MyRectangle")
		{
			MyRectangle* tmp = (MyRectangle*)shape;			
			this->GetMyGraphic()->FillRectangle(_stroke,
				tmp->GetX()+tmp->GetWidth(), 
				tmp->GetY()+_strokeWidth,
				_strokeWidth,
				tmp->GetHeight());			
			this->GetMyGraphic()->FillRectangle(_stroke,
				tmp->GetX()+_strokeWidth,
				tmp->GetY()+tmp->GetHeight(),
				tmp->GetWidth(),
				_strokeWidth);			
		}
	}

public:
	MyShadow() {
	}
	MyShadow(char stroke[], float strokeWidth) {
		_stroke = stroke;		
		_strokeWidth = strokeWidth;
	}
	void Draw() {
		this->DrawShadow();
		MyEffect::Draw();		
	}
};
//Highlight effect - derived class
class MyHighlight : public MyEffect
{
private:
	float _strokeWidth;
	char* _stroke;

private:
	void DrawHighlight() {
		if(shape->GetName() == "MyRectangle")
		{
			MyRectangle* tmp = (MyRectangle*)shape;			
		}
		else if(shape->GetName() == "MyEllipse")
		{
			MyEllipse* tmp = (MyEllipse*)shape;
			this->GetMyGraphic()->DrawEllipse(_stroke, _strokeWidth, 
				tmp->GetX() - _strokeWidth, 
				tmp->GetY() - _strokeWidth, 
				tmp->GetWidth() + _strokeWidth*2, 
				tmp->GetHeight() + _strokeWidth*2);
		}
	}

public:
	MyHighlight(char stroke[], float strokeWidth) {
		_stroke = stroke;		
		_strokeWidth = strokeWidth;
	}
	void Draw() {
		MyEffect::Draw();
		this->DrawHighlight();
	}
};
//Border effect - derived class
class MyBorder : public MyEffect
{
private:
	float _strokeWidth;
	char* _stroke;

private:
	void DrawBorder() {
		if(shape->GetName() == "MyRectangle")
		{
			MyRectangle* tmp = (MyRectangle*)shape;
			this->GetMyGraphic()->FillEllipse(_stroke, tmp->GetX()-_strokeWidth/2, tmp->GetY()-_strokeWidth/2, _strokeWidth, _strokeWidth);
			this->GetMyGraphic()->FillEllipse(_stroke, tmp->GetX()+tmp->GetWidth()-_strokeWidth/2, tmp->GetY()-_strokeWidth/2, _strokeWidth, _strokeWidth);
			this->GetMyGraphic()->FillEllipse(_stroke, tmp->GetX()-_strokeWidth/2, tmp->GetY()+tmp->GetHeight()-_strokeWidth/2, _strokeWidth, _strokeWidth);
			this->GetMyGraphic()->FillEllipse(_stroke, tmp->GetX()+tmp->GetWidth()-_strokeWidth/2, tmp->GetY()+tmp->GetHeight()-_strokeWidth/2, _strokeWidth, _strokeWidth);

			//top
			this->GetMyGraphic()->FillRectangle(_stroke, 
				tmp->GetX()+tmp->GetWidth()/2-_strokeWidth/2, tmp->GetY()-_strokeWidth/2, 
				_strokeWidth, _strokeWidth);
			//left
			this->GetMyGraphic()->FillRectangle(_stroke, 
				tmp->GetX()-_strokeWidth/2, tmp->GetY()+tmp->GetHeight()/2-_strokeWidth/2, 
				_strokeWidth, _strokeWidth);
			//bottom
			this->GetMyGraphic()->FillRectangle(_stroke, 
				tmp->GetX()+tmp->GetWidth()/2-_strokeWidth/2, tmp->GetY()+tmp->GetHeight()-_strokeWidth/2, 
				_strokeWidth, _strokeWidth);
			//right
			this->GetMyGraphic()->FillRectangle(_stroke, 
				tmp->GetX()+tmp->GetWidth()-_strokeWidth/2, tmp->GetY()+tmp->GetHeight()/2-_strokeWidth/2, 
				_strokeWidth, _strokeWidth);
		}
		else if(shape->GetName() == "MyEllipse")
		{
			MyEllipse* tmp = (MyEllipse*)shape;			
		}
		else if(shape->GetName() == "MyLozenge")
		{
			MyLozenge* tmp = (MyLozenge*)shape;
			this->GetMyGraphic()->FillEllipse(_stroke, tmp->GetX()-_strokeWidth/2, tmp->GetY()-_strokeWidth/2, _strokeWidth, _strokeWidth);
			this->GetMyGraphic()->FillEllipse(_stroke, tmp->GetX()+tmp->GetWidth()-_strokeWidth/2, tmp->GetY()-_strokeWidth/2, _strokeWidth, _strokeWidth);
			this->GetMyGraphic()->FillEllipse(_stroke, tmp->GetX()-_strokeWidth/2, tmp->GetY()+tmp->GetHeight()-_strokeWidth/2, _strokeWidth, _strokeWidth);
			this->GetMyGraphic()->FillEllipse(_stroke, tmp->GetX()+tmp->GetWidth()-_strokeWidth/2, tmp->GetY()+tmp->GetHeight()-_strokeWidth/2, _strokeWidth, _strokeWidth);

			//top
			this->GetMyGraphic()->FillRectangle(_stroke, 
				tmp->GetX()+tmp->GetWidth()/2-_strokeWidth/2, tmp->GetY()-_strokeWidth/2, 
				_strokeWidth, _strokeWidth);
			//left
			this->GetMyGraphic()->FillRectangle(_stroke, 
				tmp->GetX()-_strokeWidth/2, tmp->GetY()+tmp->GetHeight()/2-_strokeWidth/2, 
				_strokeWidth, _strokeWidth);
			//bottom
			this->GetMyGraphic()->FillRectangle(_stroke, 
				tmp->GetX()+tmp->GetWidth()/2-_strokeWidth/2, tmp->GetY()+tmp->GetHeight()-_strokeWidth/2, 
				_strokeWidth, _strokeWidth);
			//right
			this->GetMyGraphic()->FillRectangle(_stroke, 
				tmp->GetX()+tmp->GetWidth()-_strokeWidth/2, tmp->GetY()+tmp->GetHeight()/2-_strokeWidth/2, 
				_strokeWidth, _strokeWidth);
		}
	}

public:
	MyBorder(char stroke[], float strokeWidth) {
		_stroke = stroke;		
		_strokeWidth = strokeWidth;
	}
	void Draw() {
		MyEffect::Draw();
		this->DrawBorder();
	}
};